package com.hospital.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.hospital.activity.R;

import java.util.HashMap;
import java.util.List;

/**
 * Created by wangjun on 2015/7/1.
 */
public class HosSelectAdapter extends BaseAdapter {

private List<HashMap<String, String>> objects;
    protected Context context;


    public HosSelectAdapter(Context context1, List<HashMap<String, String>> object){
        context=context1;
        objects=object;

    }


    @Override
    public int getCount() {
        return objects.size();
    }

    @Override
    public Object getItem(int i) {

        if (i >= objects.size())
            return null;
        return objects.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (null == view) {

            view = View.inflate(context, R.layout.hos_select_list, null);
            holder = new ViewHolder();
            holder.docname=(TextView) view.findViewById(R.id.text_name);
            holder.hosname=(TextView)view.findViewById(R.id.hos_name);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.docname.setText(objects.get(i).get("doc_name"));
        holder.docname.setText(objects.get(i).get("hos_name"));
        final HashMap has=objects.get(i);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Toast.makeText(view.getContext(),has.get("doc_name")+"",Toast.LENGTH_LONG).show();
            }
        });
        return view;
    }


  public final  class  ViewHolder{
   public TextView docname;
    public   TextView hosname;

  }
}
